﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Toeplitz
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(' ');
            int m = int.Parse(tokens[0]);
            int n = int.Parse(tokens[1]);

            int[,] matrix = new int[m,n];
            
            for(int i = 0; i < m; i ++)
            {
                string[] tmp = Console.ReadLine().Split(' ');
                for (int j = 0; j < n; j++) matrix[i,j] = int.Parse(tmp[j]);
            }
            bool ok = true;
            //(0,0)开始
            for (int j = 0; j < n; j ++)//起始j
            {
                int std = matrix[0,j];                
                for(int i = 1; i < m && j + i < n; i ++)
                {
                    //(i,j + i)
                    if(matrix[i,j + i] != std)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok == false)
                    break;
            }
            //(1,0)开始
            for(int i = 1; i < m; i ++)
            {
                int std = matrix[i,0];
                for(int j = 1; j < n && j + i < m; j ++)
                {
                    //(i + j, j)
                    if(matrix[i + j,j] != std)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok == false)
                    break;
            }
            //做出判断
            if (ok) Console.WriteLine("Toeplitz");
            else
            {
                Console.WriteLine("Not Toeplitz");
            }
            Console.ReadKey();
        }
    }
}
